package org.example.myleet.p789;

public class Solution {
    public boolean escapeGhosts(int[][] ghosts, int[] target) {
        int myDistance = manhattanDistance(new int[]{0, 0}, target);
        for (int[] ghost : ghosts) {
            int ghostDistance = manhattanDistance(ghost, target);
            if (ghostDistance <= myDistance) {
                return false;
            }
        }
        return true;
    }

    private int manhattanDistance(int[] from, int[] target) {
        return Math.abs(target[0] - from[0]) + Math.abs(target[1] - from[1]);
    }
}
